#ifndef TINX_IDE_H
#define TINX_IDE_H

#include <tinx/lock.h>

#define SECTOR_SIZE 512

typedef enum ide_iotype_t
{
    IDE_IO_TYPE_PIO,
    IDE_IO_TYPE_UDMA
} ide_iotype_t;

typedef struct ide_disk_t
{
    dev_t dev;
    u8 selector;
    u32 sectors;
    struct ide_ctrl_t *ctrl;
} ide_disk_t;

typedef struct ide_prd_t
{
    u32 paddr;
    u16 size;
    u16 flags;
} _packed ide_prd_t;

typedef struct ide_ctrl_t
{
    lock_t lock;
    u16 iobase;
    u16 bmbase;
    u8 irq;
    ide_iotype_t iotype;
    struct ide_prd_t prd;
    struct task_t *waiter;
    struct ide_disk_t devices[2];
} ide_ctrl_t;

#endif